package leetcode100;

// TODO 脑筋急转弯 | 数组双指针 【-】 盛最多水的容器
// TODO https://leetcode.cn/problems/container-with-most-water/solution/shuang-zhi-zhen-jie-fa-xiang-qing-jian-d-2diq/

public class lc100_0011 {

    public int maxArea(int[] height) {
        int n = height.length;
        int l = 0, r = n-1;
        int area = 0, maxArea = 0;

        while (l < r) {
            area = Math.min(height[l], height[r]) * (r - l);
            if (area > maxArea)
                maxArea = area;

            if (height[l] > height[r])
                r--;
            else
                l++;
        }
        return maxArea;
    }

}
